from django.shortcuts import render
# todo:分页案例
# Create your views here.
from view_study.models import *
from django.core.paginator import Paginator
from django.views.decorators.cache import cache_page


# @cache_page(60) # 单个视图函数缓存60s
def page(request, index):
    post_list = Post.objects.all()
    post = Paginator(post_list, 1)  # 一页一个对象
    p = post.page(index)  # index是前端传过来的页码
    # post_name_list = [post.name for post in post_list]
    return render(request, "page/index.html", context={"post_list": p})
